import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/Main.vue'
import Home from '../views/home/Home.vue'
import Strategy from '../views/strategy/Strategy.vue'
import Competition from '../views/competition/Competition.vue'
import Article from '../views/article-page/Article.vue'
import Hero from '../views/hero-page/Hero.vue'
import Game from '../views/game/Game.vue'

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Main',
    component: Main,
    children:[
      // {path:'/', redirect:'/'},
      {path:'/',name:'Home',component:Home},
      {path:'/strategy',name:'strategy',component:Strategy},
      {path:'/game',name:'game',component:Game},
      {path:'/competition',name:'competition',component:Competition},
      // props:true 所有在path里的参数均映射为主键里的参数
      {path:'/articles/:id',name:'Home',component:Article,props:true},
    ]
  },
  {path:'/heroes/:id',name:'hero',component:Hero,props:true},
]

const router = new VueRouter({
  routes,
})

export default router
